package com.itheima.service.cargo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.cargo.FinanceDao;
import com.itheima.domain.cargo.Finance;
import com.itheima.domain.cargo.FinanceExample;
import com.itheima.service.cargo.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class FinanceServiceImpl implements FinanceService {
    @Autowired
    private FinanceDao financeDao;
    @Override
    public Finance findById(String id) {
        return financeDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(Finance finance) {
        financeDao.insert(finance);
    }

    @Override
    public void update(Finance finance) {

    }

    @Override
    public void delete(String id) {
        financeDao.deleteByPrimaryKey(id);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, FinanceExample example) {
        //设置分页参数
        PageHelper.startPage(pageNum,pageSize);
        //查询全部
        List<Finance> list = financeDao.selectByExample(example);
        //构造返回值
        return new PageInfo(list);
    }
}
